<template>
	<view>
		<carHeader :title="'输入核销码'"></carHeader>
		<view class="top">
			<view class="input1">
				输入核销码
			</view>
			<view class="u-demo-block__content">
				<!-- #ifndef APP-NVUE -->
				<u-input v-model="value" @input="handleInput">
				<!-- #endif -->
					<!-- #ifdef APP-NVUE -->
					<u--input placeholder="后置插槽">
					<!-- #endif -->
						<template slot="suffix">
							<u-button @tap="getCode">识别</u-button>
						</template>
				<!-- #ifndef APP-NVUE -->
				</u-input>
				<!-- #endif -->
				<!-- #ifdef APP-NVUE -->
				</u--input>
				<!-- #endif -->
			</view>
		</view>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: '',
				list:[]
			};
		},
		methods: {
			handleInput(e) {
				console.log(e);
				this.value = e;
			},
			getCode() {
				uni.request({
					url: 'http://localhost:8080/carShopService/hexiao/selectById?ordVerificationCode',
					data: {
						ordVerificationCode: this.value
					},
					success: (res) => {
					          if (res.statusCode === 200) {
					            if (res.data && res.data.length > 0) { // 假设返回的数据是一个数组
								  this.list = res.data;
					              console.log('查询结果:', this.list);
					              // 查询成功后跳转到目标页面
					              uni.navigateTo({
					                url: '/pages/hexiao1/hexiao1?value=' + encodeURIComponent(this.value)+'&data='+encodeURIComponent(JSON.stringify(this.list))
					              });
					            } else {
					              console.log('未找到匹配的数据');
					            }
					          } else {
					            console.error('查询失败:', res);
					          }
					        },
					fail: (err) => {
						console.error('请求失败:', err);
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.top {

		width: 720rpx;
		height: 160rpx;
		background-color: white;
		position: absolute;
		border-radius: 30rpx;
		left: 15rpx;
		top: 90rpx;
		display: flex;

		justify-content: center;
		align-items: center;

		.input1 {
			color: #2E80F9;
		}

		.u-input {
			height: 60rpx;
			border-radius: 50rpx;

			.u-button {
				background-color: #2E80F9;
				color: white;
				width: 150rpx;
				border-radius: 40rpx;
				left: 15rpx;
			}

		}
	}
</style>